package com.jy.api.patient;

import com.jy.api.patient.dto.BingRenXXDto;
import com.jy.api.patient.dto.PatientIndexDto;
import com.jy.api.okhttp.QyjkHealthdcClient;
import com.jy.framework.base.entity.Page;
import com.jy.framework.base.entity.Result;
import java.util.List;

/**
 * 对接平台1.0EMPI实现类
 *
 * @author Alen
 * @date 2024/7/16 14:46
 * @since 2024/7/16 14:46
 */
public class PatientAPIv1Impl implements PatientAPI {

    private QyjkHealthdcClient qyjkHealthdcClient;

    public PatientAPIv1Impl(QyjkHealthdcClient restTemplate){
        this.qyjkHealthdcClient = restTemplate;
    }
    @Override
    public Result<List<BingRenXXDto>> getHLHTJMJCSYList(String eid, String appId) {
        Result<List<BingRenXXDto>> result = qyjkHealthdcClient.pix(eid,appId);
        if(result.isSuccess()){
            return result;
        }
        return null;
    }

    @Override
    public Result<Page<BingRenXXDto>> pageHLHTJMList(String hyzk, String swbj, String qscsrq, String zzcsrq, String xbdm, Integer from, Integer maxCount) {
        Result<List<BingRenXXDto>> result = qyjkHealthdcClient.patientPageQuery(hyzk,swbj,qscsrq,zzcsrq,xbdm,from,maxCount);
        if(result.isSuccess()){
            List<BingRenXXDto> data = result.getData();
            Page page = new Page();
            page.setRecords(data);
            return Result.success(page);
        }
        return null;
    }

    @Override
    public BingRenXXDto findBySFZ(String zhengJianHM) {
        Result<BingRenXXDto> result = qyjkHealthdcClient.patientQueryByIdCard(zhengJianHM);
        if(result.isSuccess()){
            BingRenXXDto data = result.getData();
            return data;
        }
        return null;
    }

    @Override
    public BingRenXXDto findById(String id) {
        Result<BingRenXXDto> re = qyjkHealthdcClient.patientInfo(id);
        return re.getData();
    }

    @Override
    public String insertOrUpdate(BingRenXXDto bingRenXXDto) {
        Result<String> re = qyjkHealthdcClient.insertOrUpdate(bingRenXXDto);
        return re.getData();
    }

    @Override
    public Result<List<PatientIndexDto>> patientIndexs(String xingMing, Integer type, String zhengJianHM) {
        return qyjkHealthdcClient.patientIndexs(xingMing, type, zhengJianHM);
    }

    @Override
    public Result<PatientIndexDto> patientIndex(String empi) {
        return qyjkHealthdcClient.patientIndex(empi);
    }
}
